﻿using System;
using System.Collections.Generic;
using System.Text;
using ORM.Annotations;

namespace Motorbike.Model
{
    /// <summary>
    /// 货运订价协议
    /// </summary>
    [EntityTable("b_pricing_agreement")]
    public class PricingAgreement : Domain.Commons.DomainObject
    {
        [EntityFeild("company_id")]
        public string CompanyId { get; set; }

        [EntityFeild("create_date")]
        public DateTime CreateTime { get; set; }

        [EntityFeild("create_user_id")]
        public string CreateUser { get; set; }

        private IList<PricingAgreementItem> _pricingItems;

        public IList<PricingAgreementItem> PricingItems
        {
            get { return _pricingItems; }
            set { _pricingItems = value; }
        }

        public void AddItem(PricingAgreementItem item)
        {
            if (null == item)
            {
                return;
            }
            if (null == this._pricingItems)
            {
                this._pricingItems = new List<PricingAgreementItem>();
            }
            if (!this._pricingItems.Contains(item))
            {
                this._pricingItems.Add(item);
            }
        }

        public static PricingAgreement create(User creater,string companyId)
        {
            PricingAgreement agreement = new PricingAgreement();
            agreement.CompanyId = companyId;
            agreement.CreateTime = DateTime.Now;
            agreement.CreateUser = creater.Id;
            return agreement;
        }
    }
}
